package cn.kgc.microservicecloudconsumercategory80;

import cn.kgc.MySelfRule;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@RibbonClient(name = "MICROSERVICECLOUD-PROVIDER-CATEGORY",configuration = MySelfRule.class)
@EnableEurekaClient
@SpringBootApplication
public class MicroservicecloudConsumerCategory80Application {

    public static void main(String[] args) {
        SpringApplication.run(MicroservicecloudConsumerCategory80Application.class, args);
    }

    @Bean
//    默认是轮询
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }


//随机策略
    @Bean
    public IRule myRule(){
        return new RandomRule();
    }

}
